﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;

namespace FACUI.BasicClass
{
    /// <summary>
    /// 灯或按钮
    /// </summary>
    public class DHAN : Sharp
    {
        private static Point temp1;

        public DHAN(MapData mapData, Point pt, int d, string subType)
            : base(mapData, pt, d)
        {
            if ("0".Equals(subType))
            {
                base.digitList.Add(new Digit("定位", "DCBS_L", 1));
                base.digitList.Add(new Digit("反位", "DCBS_U", 1));
            }
            else
            {
                base.digitList.Add(new Digit("有信号", "DHAN_Y", 1));
                base.digitList.Add(new Digit("绿灯", "DHAN_L", 1));
                base.digitList.Add(new Digit("黄灯", "DHAN_U", 1));
                base.digitList.Add(new Digit("红灯", "DHAN_H", 1));
                base.digitList.Add(new Digit("蓝灯", "DHAN_A", 1));
                base.digitList.Add(new Digit("白灯", "DHAN_B", 1));
            }
            base.changeStep = 1;
            base.text = "";
            base.sharpType = "sbDHAN";
            this.changeSubType(subType);
        }

        public override void addSize(int r)
        {
            if ("6".Equals(base.subType) || "7".Equals(base.subType))
            {
                if (((base.sizeDefineHeight > 1) && (base.sizeDefineWidth > 1)) || (r > 0))
                {
                    base.sizeDefineWidth += r;
                }
                if (base.sizeDefineWidth <= 1)
                {
                    base.sizeDefineWidth = 2;
                }
                if (base.sizeDefineHeight <= 1)
                {
                    base.sizeDefineHeight = 2;
                }
                this.resetSize();
            }
        }

        public override void addSize(int d, Point oldPoint, int oldWidth, int oldHeight, int width, int height)
        {
            if ("6".Equals(base.subType) || "7".Equals(base.subType))
            {
                switch ((d % 8))
                {
                    case 0:
                        base.pointY = oldPoint.Y + height;
                        base.sizeDefineHeight = oldHeight - height;
                        break;

                    case 1:
                        base.pointY = oldPoint.Y + height;
                        base.sizeDefineHeight = oldHeight - height;
                        base.sizeDefineWidth = oldWidth + width;
                        break;

                    case 2:
                        base.sizeDefineWidth = oldWidth + width;
                        break;

                    case 3:
                        base.sizeDefineHeight = oldHeight + height;
                        base.sizeDefineWidth = oldWidth + width;
                        break;

                    case 4:
                        base.sizeDefineHeight = oldHeight + height;
                        break;

                    case 5:
                        base.pointX = oldPoint.X + width;
                        base.sizeDefineWidth = oldWidth - width;
                        base.sizeDefineHeight = oldHeight + height;
                        break;

                    case 6:
                        base.pointX = oldPoint.X + width;
                        base.sizeDefineWidth = oldWidth - width;
                        break;

                    case 7:
                        base.pointX = oldPoint.X + width;
                        base.pointY = oldPoint.Y + height;
                        base.sizeDefineWidth = oldWidth - width;
                        base.sizeDefineHeight = oldHeight - height;
                        break;
                }
                if (base.sizeDefineWidth <= 1)
                {
                    base.sizeDefineWidth = 2;
                }
                if (base.sizeDefineHeight <= 1)
                {
                    base.sizeDefineHeight = 2;
                }
                this.resetSize();
            }
        }

        public override bool changeSubType(string newSubType)
        {
            if (!((((("0".Equals(newSubType) || "3".Equals(newSubType)) || ("4".Equals(newSubType) || "5".Equals(newSubType))) || (("6".Equals(newSubType) || "7".Equals(newSubType)) || ("2".Equals(newSubType) || "1".Equals(newSubType)))) || "-1".Equals(newSubType)) || "-2".Equals(newSubType)))
            {
                return false;
            }
            if ("2".Equals(newSubType) || "1".Equals(newSubType))
            {
                int num1 = base.direction % 4;
                base.sizeDefine = new Size(1, 1);
            }
            else
            {
                int num2 = base.direction % 4;
                base.sizeDefine = new Size(2, 2);
            }
            base.subType = newSubType;
            this.resetSize();
            return true;
        }

        public override void checkLine(int[][][] array4checkLine)
        {
            if ("-1".Equals(base.subType) || "-2".Equals(base.subType))
            {
                for (int i = 0; i < base.sizeDefineWidth; i++)
                {
                    Sharp.tryAddArray4checkLine(array4checkLine, base.pointX + i, base.pointY + 1, 0);
                }
            }
        }

        public override void createDigit(string kglDesc)
        {
            string[] strArray2;
            string[] strArray = kglDesc.Split(new char[] { ',' });
            Digit digit = null;
            if ("0".Equals(base.subType))
            {
                strArray2 = strArray[1].Split(new char[] { ';' });
                digit = base.getDigit("DCBS_L");
                digit.name = strArray2[0];
                digit.isLogic = "1".Equals(strArray2[1]);
                digit.ad = int.Parse(strArray2[2]);
                strArray2 = strArray[2].Split(new char[] { ';' });
                digit = base.getDigit("DCBS_U");
                digit.name = strArray2[0];
                digit.isLogic = "1".Equals(strArray2[1]);
                digit.ad = int.Parse(strArray2[2]);
            }
            else
            {
                strArray2 = strArray[1].Split(new char[] { ';' });
                digit = base.getDigit("DHAN_Y");
                digit.name = strArray2[0];
                digit.isLogic = "1".Equals(strArray2[1]);
                digit.ad = int.Parse(strArray2[2]);
                strArray2 = strArray[2].Split(new char[] { ';' });
                digit = base.getDigit("DHAN_L");
                digit.name = strArray2[0];
                digit.isLogic = "1".Equals(strArray2[1]);
                digit.ad = int.Parse(strArray2[2]);
                strArray2 = strArray[3].Split(new char[] { ';' });
                digit = base.getDigit("DHAN_U");
                digit.name = strArray2[0];
                digit.isLogic = "1".Equals(strArray2[1]);
                digit.ad = int.Parse(strArray2[2]);
                strArray2 = strArray[4].Split(new char[] { ';' });
                digit = base.getDigit("DHAN_H");
                digit.name = strArray2[0];
                digit.isLogic = "1".Equals(strArray2[1]);
                digit.ad = int.Parse(strArray2[2]);
                strArray2 = strArray[5].Split(new char[] { ';' });
                digit = base.getDigit("DHAN_A");
                digit.name = strArray2[0];
                digit.isLogic = "1".Equals(strArray2[1]);
                digit.ad = int.Parse(strArray2[2]);
                strArray2 = strArray[6].Split(new char[] { ';' });
                digit = base.getDigit("DHAN_B");
                digit.name = strArray2[0];
                digit.isLogic = "1".Equals(strArray2[1]);
                digit.ad = int.Parse(strArray2[2]);
            }
        }

        public override double distance(Point p, Size r)
        {
            return 0.0;
        }

        public override void draw(Graphics g, MapSet ct, Pen usePen)
        {
            if (base.inShowArea())
            {
                Point[] pointArray;
                Point[] pointArray2;
                this.resetSize();
                Rectangle layoutRectangle = new Rectangle(((this.rectReal.Left * ct.gridsize.Width) / 2) + ct.offset.X, ((this.rectReal.Top * ct.gridsize.Height) / 2) + ct.offset.Y, Sharp.txtAreaSize.Width * ct.gridsize.Width, Sharp.txtAreaSize.Height * ct.gridsize.Width);
                StringFormat format = new StringFormat(StringFormatFlags.NoClip)
                {
                    Alignment = StringAlignment.Center,
                    LineAlignment = StringAlignment.Center
                };
                layoutRectangle.Y = layoutRectangle.Top + (ct.gridsize.Height / 2);
                format.LineAlignment = StringAlignment.Near;
                format.Alignment = StringAlignment.Center;
                base.linePen.Color = base.lineColor;
                base.linePen.Width = 1f;
                temp1 = base.grid2pix(base.point, ct.gridsize, ct.offset);
                Pen pen = (usePen != null) ? usePen : base.linePen;
                pen.Width = (ct.gridsize.Width >= 8) ? pen.Width : 1f;
                if (!"0".Equals(base.subType))
                {
                    pen.Color = (ct.gridsize.Width >= 6) ? pen.Color : Color.Black;
                }
                if (MapData.开始打印)
                {
                    pen = new Pen(Color.Black, pen.Width);
                }
                if ("-1".Equals(base.subType) || "-2".Equals(base.subType))
                {
                    pointArray2 = new Point[] { base.grid2pix(new Point(base.pointX + 1, base.pointY), ct.gridsize, ct.offset), base.grid2pix(new Point(base.pointX, base.pointY + 1), ct.gridsize, ct.offset), base.grid2pix(new Point(base.pointX + 2, base.pointY + 1), ct.gridsize, ct.offset), base.grid2pix(new Point(base.pointX + 1, base.pointY), ct.gridsize, ct.offset) };
                    pointArray = pointArray2;
                    g.DrawLines(pen, pointArray);
                    layoutRectangle.X = base.pointX + 1;
                    layoutRectangle.Y = base.pointY + 10;
                    format.LineAlignment = StringAlignment.Near;
                    format.Alignment = StringAlignment.Center;
                }
                else if ("0".Equals(base.subType) || "3".Equals(base.subType))
                {
                    if ((base.direction == 0) || (2 == base.direction))
                    {
                        //g.DrawEllipse(pen, (float)((temp1.X + ((base.sizeDefineWidth * ct.gridsize.Width) / 2)) - (ct.gridsize.Width * 0.3)), (float)(temp1.Y + (ct.gridsize.Width * 0.2)), (float)(ct.gridsize.Width * 0.6), (float)(ct.gridsize.Height * 0.6));
                        layoutRectangle.X = (layoutRectangle.Left - (layoutRectangle.Width / 2)) + (ct.gridsize.Width / 2);
                        layoutRectangle.Y = layoutRectangle.Top + (ct.gridsize.Height / 2);
                        format.LineAlignment = StringAlignment.Near;
                        format.Alignment = StringAlignment.Center;
                    }
                    else
                    {
                        //g.DrawEllipse(pen, (float)((temp1.X + ((base.sizeDefineWidth * ct.gridsize.Width) / 2)) - (ct.gridsize.Width * 0.3)), (float)(temp1.Y + (ct.gridsize.Width * 1.2)), (float)(ct.gridsize.Width * 0.6), (float)(ct.gridsize.Height * 0.6));
                        layoutRectangle.X = (layoutRectangle.Left - (layoutRectangle.Width / 2)) + (ct.gridsize.Width / 2);
                        layoutRectangle.Y = (layoutRectangle.Top - layoutRectangle.Height) - ((int)(ct.gridsize.Height * 0.2));
                        format.LineAlignment = StringAlignment.Far;
                        format.Alignment = StringAlignment.Center;
                    }
                }
                else if ("1".Equals(base.subType) && ((base.direction == 0) || (2 == base.direction)))
                {
                    base.linePen.Width = 1f;
                    //g.DrawEllipse(pen, (float)(temp1.X + (ct.gridsize.Width * 0.2)), (float)(temp1.Y + (ct.gridsize.Height * 0.7)), (float)(ct.gridsize.Width * 0.6), (float)(ct.gridsize.Height * 0.6));
                    //g.FillEllipse(Brushes.Black, (float)(temp1.X + (ct.gridsize.Width * 0.2)), (float)(temp1.Y + (ct.gridsize.Height * 0.7)), (float)(ct.gridsize.Width * 0.6), (float)(ct.gridsize.Height * 0.6));
                }
                else if ("2".Equals(base.subType) && ((base.direction == 0) || (2 == base.direction)))
                {
                    //g.DrawEllipse(pen, (float)(temp1.X + (ct.gridsize.Width * 0.2)), (float)(temp1.Y + (ct.gridsize.Height * 0.2)), (float)(ct.gridsize.Width * 0.6), (float)(ct.gridsize.Height * 0.6));
                }
                else if ("4".Equals(base.subType))
                {
                    base.linePen.Width = 1f;
                    //g.DrawEllipse(pen, (float)((temp1.X + ((base.sizeDefineWidth * ct.gridsize.Width) / 2)) - (ct.gridsize.Width * 0.3)), (float)(temp1.Y + (ct.gridsize.Height * 0.2)), (float)(ct.gridsize.Width * 0.6), (float)(ct.gridsize.Height * 0.6));
                    //g.DrawEllipse(pen, (float)((temp1.X + ((base.sizeDefineWidth * ct.gridsize.Width) / 2)) - (ct.gridsize.Width * 0.15)), (float)(temp1.Y + (ct.gridsize.Height * 0.35)), (float)(ct.gridsize.Width * 0.3), (float)(ct.gridsize.Height * 0.3));
                    layoutRectangle.X = (layoutRectangle.Left - (layoutRectangle.Width / 2)) + (ct.gridsize.Width / 2);
                    layoutRectangle.Y = layoutRectangle.Top + (ct.gridsize.Height / 2);
                    format.LineAlignment = StringAlignment.Near;
                    format.Alignment = StringAlignment.Center;
                }
                else if ("5".Equals(base.subType))
                {
                    g.DrawRectangle(pen, (float)(temp1.X + (ct.gridsize.Width * 0.2)), (float)(temp1.Y - (ct.gridsize.Height * 0.3)), (float)(ct.gridsize.Width * 0.6), (float)(ct.gridsize.Height * 0.6));
                    layoutRectangle.X = (layoutRectangle.Left - (layoutRectangle.Width / 2)) + (ct.gridsize.Width / 2);
                    layoutRectangle.Y = layoutRectangle.Top + (ct.gridsize.Height / 2);
                    format.LineAlignment = StringAlignment.Near;
                    format.Alignment = StringAlignment.Center;
                }
                else if ("6".Equals(base.subType))
                {
                    if ((base.direction == 0) || (2 == base.direction))
                    {
                        pointArray2 = new Point[] { new Point(temp1.X, temp1.Y + (ct.gridsize.Height / 2)), new Point(temp1.X, (temp1.Y + (base.sizeDefineHeight * ct.gridsize.Height)) - ((int)(((double)ct.gridsize.Height) / 2.0))), new Point(temp1.X + ((base.sizeDefineWidth - 1) * ct.gridsize.Width), (temp1.Y + (base.sizeDefineHeight * ct.gridsize.Height)) - ((int)(((double)ct.gridsize.Height) / 2.0))), new Point(temp1.X + ((base.sizeDefineWidth - 1) * ct.gridsize.Width), temp1.Y + (base.sizeDefineHeight * ct.gridsize.Height)), new Point(temp1.X + (base.sizeDefineWidth * ct.gridsize.Width), temp1.Y + ((int)(((double)(base.sizeDefineHeight * ct.gridsize.Height)) / 2.0))), new Point(temp1.X + ((base.sizeDefineWidth - 1) * ct.gridsize.Width), temp1.Y), new Point(temp1.X + ((base.sizeDefineWidth - 1) * ct.gridsize.Width), temp1.Y + (ct.gridsize.Height / 2)), new Point(temp1.X, temp1.Y + ((int)(((double)ct.gridsize.Height) / 2.0))) };
                        pointArray = pointArray2;
                        g.DrawLines(pen, pointArray);
                    }
                    else
                    {
                        pointArray2 = new Point[] { new Point(temp1.X, temp1.Y + ((int)(((double)(base.sizeDefineHeight * ct.gridsize.Height)) / 2.0))), new Point(temp1.X + ct.gridsize.Width, temp1.Y + (base.sizeDefineHeight * ct.gridsize.Height)), new Point(temp1.X + ct.gridsize.Width, (temp1.Y + (base.sizeDefineHeight * ct.gridsize.Height)) - ((int)(((double)ct.gridsize.Height) / 2.0))), new Point(temp1.X + (base.sizeDefineWidth * ct.gridsize.Width), (temp1.Y + (base.sizeDefineHeight * ct.gridsize.Height)) - ((int)(((double)ct.gridsize.Height) / 2.0))), new Point(temp1.X + (base.sizeDefineWidth * ct.gridsize.Width), temp1.Y + (ct.gridsize.Height / 2)), new Point(temp1.X + ct.gridsize.Width, temp1.Y + (ct.gridsize.Height / 2)), new Point(temp1.X + ct.gridsize.Width, temp1.Y), new Point(temp1.X, temp1.Y + ((int)(((double)(base.sizeDefineHeight * ct.gridsize.Height)) / 2.0))) };
                        pointArray = pointArray2;
                        g.DrawLines(pen, pointArray);
                    }
                }
                else if ("7".Equals(base.subType))
                {
                    if (0 == base.direction)
                    {
                        pointArray2 = new Point[] { new Point(temp1.X, temp1.Y + (ct.gridsize.Height / 2)), new Point(temp1.X, temp1.Y + ((int)(((double)(base.sizeDefineHeight * ct.gridsize.Height)) / 2.0))), new Point(temp1.X + (base.sizeDefineWidth * ct.gridsize.Width), temp1.Y + ((int)(((double)(base.sizeDefineHeight * ct.gridsize.Height)) / 2.0))), new Point(temp1.X + ((base.sizeDefineWidth - 1) * ct.gridsize.Width), temp1.Y), new Point(temp1.X + ((base.sizeDefineWidth - 1) * ct.gridsize.Width), temp1.Y + (ct.gridsize.Height / 2)), new Point(temp1.X, temp1.Y + ((int)(((double)ct.gridsize.Height) / 2.0))) };
                        pointArray = pointArray2;
                        g.DrawLines(pen, pointArray);
                    }
                    else if (1 == base.direction)
                    {
                        pointArray2 = new Point[] { new Point(temp1.X, temp1.Y + (ct.gridsize.Height / 2)), new Point(temp1.X + ct.gridsize.Width, temp1.Y + ((int)(((double)((base.sizeDefineHeight + 1) * ct.gridsize.Height)) / 2.0))), new Point(temp1.X + ct.gridsize.Width, temp1.Y + ((int)(((double)(base.sizeDefineHeight * ct.gridsize.Height)) / 2.0))), new Point(temp1.X + (base.sizeDefineWidth * ct.gridsize.Width), temp1.Y + ((int)(((double)(base.sizeDefineHeight * ct.gridsize.Height)) / 2.0))), new Point(temp1.X + (base.sizeDefineWidth * ct.gridsize.Width), temp1.Y + (ct.gridsize.Height / 2)), new Point(temp1.X, temp1.Y + (ct.gridsize.Height / 2)) };
                        pointArray = pointArray2;
                        g.DrawLines(pen, pointArray);
                    }
                    else if (2 == base.direction)
                    {
                        pointArray2 = new Point[] { new Point(temp1.X, temp1.Y + (ct.gridsize.Height / 2)), new Point(temp1.X, temp1.Y + ((int)(((double)(base.sizeDefineHeight * ct.gridsize.Height)) / 2.0))), new Point(temp1.X + ((base.sizeDefineWidth - 1) * ct.gridsize.Width), temp1.Y + ((int)(((double)(base.sizeDefineHeight * ct.gridsize.Height)) / 2.0))), new Point(temp1.X + ((base.sizeDefineWidth - 1) * ct.gridsize.Width), temp1.Y + ((int)(((double)((base.sizeDefineHeight + 1) * ct.gridsize.Height)) / 2.0))), new Point(temp1.X + (base.sizeDefineWidth * ct.gridsize.Width), temp1.Y + (ct.gridsize.Height / 2)), new Point(temp1.X, temp1.Y + (ct.gridsize.Height / 2)) };
                        pointArray = pointArray2;
                        g.DrawLines(pen, pointArray);
                    }
                    else if (3 == base.direction)
                    {
                        pointArray2 = new Point[] { new Point(temp1.X, temp1.Y + ((int)(((double)(base.sizeDefineHeight * ct.gridsize.Height)) / 2.0))), new Point(temp1.X + (base.sizeDefineWidth * ct.gridsize.Width), temp1.Y + ((int)(((double)(base.sizeDefineHeight * ct.gridsize.Height)) / 2.0))), new Point(temp1.X + (base.sizeDefineWidth * ct.gridsize.Width), temp1.Y + (ct.gridsize.Height / 2)), new Point(temp1.X + ct.gridsize.Width, temp1.Y + (ct.gridsize.Height / 2)), new Point(temp1.X + ct.gridsize.Width, temp1.Y), new Point(temp1.X, temp1.Y + ((int)(((double)(base.sizeDefineHeight * ct.gridsize.Height)) / 2.0))) };
                        pointArray = pointArray2;
                        g.DrawLines(pen, pointArray);
                    }
                    layoutRectangle.X = (layoutRectangle.Left - (layoutRectangle.Width / 2)) + (ct.gridsize.Width / 2);
                    layoutRectangle.Y = layoutRectangle.Top + (ct.gridsize.Height / 2);
                    format.LineAlignment = StringAlignment.Near;
                    format.Alignment = StringAlignment.Center;
                }
                if (!base.isHideTxt && (((int)(base.txtSize * ((ct.gridsize.Width * 1.0) / 10.0))) >= 4))
                {
                    //if ("-1".Equals(base.subType) || "-2".Equals(base.subType))
                    //{
                    //    g.DrawEllipse(new Pen(Color.White), new Rectangle(base.grid2pix(new Point(base.pointX + 1, base.pointY), ct.gridsize, ct.offset) + new Size(-2, -2), new Size(4, 4)));
                    //    g.DrawEllipse(new Pen(Color.White), new Rectangle(base.grid2pix(new Point(base.pointX, base.pointY + 1), ct.gridsize, ct.offset) + new Size(-2, -2), new Size(4, 4)));
                    //    g.FillEllipse(new SolidBrush(Color.LightGreen), new Rectangle(base.grid2pix(new Point(base.pointX + 1, base.pointY), ct.gridsize, ct.offset) + new Size(-2, -2), new Size(4, 4)));
                    //    g.FillEllipse(new SolidBrush(Color.LightGreen), new Rectangle(base.grid2pix(new Point(base.pointX, base.pointY + 1), ct.gridsize, ct.offset) + new Size(-2, -2), new Size(4, 4)));
                    //    g.DrawEllipse(new Pen(Color.White), new Rectangle(base.grid2pix(new Point(base.pointX + 2, base.pointY + 1), ct.gridsize, ct.offset) + new Size(-2, -2), new Size(4, 4)));
                    //    g.FillEllipse(new SolidBrush(Color.LightGreen), new Rectangle(base.grid2pix(new Point(base.pointX + 2, base.pointY + 1), ct.gridsize, ct.offset) + new Size(-2, -2), new Size(4, 4)));
                    //}
                    if (((!"1".Equals(base.subType) && !"2".Equals(base.subType)) && !"7".Equals(base.subType)) && !"6".Equals(base.subType))
                    {
                        g.DrawString(base.text, new Font(base.txtFont, (float)((int)(base.txtSize * ((ct.gridsize.Width * 1.0) / 10.0))), FontStyle.Regular), new SolidBrush(MapData.开始打印 ? Color.Black : base.txtColor), layoutRectangle, format);
                    }
                }
            }
        }

        public override Point getPoint(char c)
        {
            return new Point(-1, -1);
        }

        public override bool hasHotPoint(int d)
        {
            return ("6".Equals(base.subType) || "7".Equals(base.subType));
        }

        public override bool hasPoint(Point pt)
        {
            return false;
        }

        public override void onSpaceChar()
        {
            if (("7".Equals(base.subType) || "6".Equals(base.subType)) || "5".Equals(base.subType))
            {
                base.direction = (base.direction + base.changeStep) % 4;
            }
            else
            {
                base.direction = (base.direction + base.changeStep) % 2;
            }
            this.resetSize();
        }

        public override void resetSize()
        {
            this.rectReal.Location = new Point(base.pointX * 2, (base.pointY * 2) - 1);
            this.rectReal.Width = 2;
            this.rectReal.Height = 2;
            if ("0".Equals(base.subType) || "3".Equals(base.subType))
            {
                if ((base.direction == 0) || (base.direction == 2))
                {
                    this.rectReal.Location = new Point(((base.pointX * 2) + base.sizeDefineWidth) - 1, base.pointY * 2);
                }
                else
                {
                    this.rectReal.Location = new Point(((base.pointX * 2) + base.sizeDefineWidth) - 1, (base.pointY * 2) + 2);
                }
            }
            else if ("4".Equals(base.subType))
            {
                this.rectReal.Location = new Point(((base.pointX * 2) + base.sizeDefineWidth) - 1, base.pointY * 2);
            }
            else if ("1".Equals(base.subType))
            {
                this.rectReal.Location = new Point(base.pointX * 2, (base.pointY * 2) + 1);
            }
            else if ("2".Equals(base.subType))
            {
                this.rectReal.Location = new Point(base.pointX * 2, base.pointY * 2);
            }
            else if ("7".Equals(base.subType))
            {
                this.rectReal.Location = new Point((base.pointX * 2) - 1, base.pointY * 2);
                this.rectReal.Width = (base.sizeDefineWidth + 1) * 2;
                this.rectReal.Height = (base.sizeDefineHeight + 2) - 1;
            }
            else if ("6".Equals(base.subType))
            {
                this.rectReal.Location = new Point((base.pointX * 2) - 1, base.pointY * 2);
                this.rectReal.Width = (base.sizeDefineWidth + 1) * 2;
                this.rectReal.Height = base.sizeDefineHeight * 2;
            }
            else if ("-1".Equals(base.subType) || "-2".Equals(base.subType))
            {
                this.rectReal.Location = new Point(base.pointX * 2, base.pointY * 2);
                this.rectReal.Width = 4;
            }
            else
            {
                this.rectReal.Width = 2;
                this.rectReal.Height = 2;
            }
        }

        public override string ToString()
        {
            StringBuilder builder = new StringBuilder("");
            builder.Append(StringUtil.TrimAndPadRight4ASCII(base.text, 1)).Append("灯或按钮");
            int result = 0;
            int.TryParse(base.subType, out result);
            switch (result)
            {
                case -2:
                    builder.Append("->脱轨器:");
                    break;

                case -1:
                    builder.Append("->有源应答器灯:");
                    break;

                case 0:
                    builder.Append("->道岔表示:");
                    break;

                case 1:
                    builder.Append("->列按:");
                    break;

                case 2:
                    builder.Append("->调按:");
                    break;

                case 3:
                    builder.Append("->单圈:");
                    break;

                case 4:
                    builder.Append("->双圈:");
                    break;

                case 5:
                    builder.Append("->方形:");
                    break;

                case 6:
                    builder.Append("->全箭头:");
                    break;

                case 7:
                    builder.Append("->半箭头:");
                    break;
            }
            builder.Append(" 坐标(").Append(base.pointX).Append(',').Append(base.pointY).Append(')');
            return builder.ToString();
        }

        public override string toStringKgl()
        {
            Digit[] digitArray = base.digitList.ToArray();
            StringBuilder builder = new StringBuilder("");
            if ("0".Equals(base.subType))
            {
                builder.Append("").Append(digitArray[0].name).Append(";").Append(digitArray[0].isLogic ? "1" : "0").Append(";").Append(digitArray[0].ad).Append(",").Append(digitArray[1].name).Append(";").Append(digitArray[1].isLogic ? "1" : "0").Append(";").Append(digitArray[1].ad);
            }
            else
            {
                try
                {
                    builder.Append("").Append(digitArray[0].name).Append(";").Append(digitArray[0].isLogic ? "1" : "0").Append(";").Append(digitArray[0].ad).Append(",").Append(digitArray[1].name).Append(";").Append(digitArray[1].isLogic ? "1" : "0").Append(";").Append(digitArray[1].ad).Append(",").Append(digitArray[2].name).Append(";").Append(digitArray[2].isLogic ? "1" : "0").Append(";").Append(digitArray[2].ad).Append(",").Append(digitArray[3].name).Append(";").Append(digitArray[3].isLogic ? "1" : "0").Append(";").Append(digitArray[3].ad).Append(",").Append(digitArray[4].name).Append(";").Append(digitArray[4].isLogic ? "1" : "0").Append(";").Append(digitArray[4].ad).Append(",").Append(digitArray[5].name).Append(";").Append(digitArray[5].isLogic ? "1" : "0").Append(";").Append(digitArray[5].ad);
                }
                catch (Exception)
                {
                }
            }
            return builder.ToString();
        }

        public override string toStringXiangshu()
        {
            if ("-1".Equals(base.subType) || "-2".Equals(base.subType))
            {
                string subType = base.subType;
                if (subType == "-2")
                {
                    subType = "-1";
                }
                return string.Concat(new object[] { 
                    base.text.Trim(), ",", base.sharpType, ",", subType, ",", (base.lineColor.R + (base.lineColor.G << 8)) + (base.lineColor.B << 0x10), ",", base.direction, ",", base.pointX, ",", base.pointY - 1, ",", base.sizeDefineWidth, ",", 
                    base.sizeDefineHeight, ",", base.txtSize, ",", ((base.txtColor.B << 0x10) + (base.txtColor.G << 8)) + base.txtColor.R, ",", base.txtFont.Trim(), ",", base.isHideTxt ? "1" : "0"
                 });
            }
            return string.Concat(new object[] { 
                base.text.Trim(), ",", base.sharpType, ",", base.subType, ",", (base.lineColor.R + (base.lineColor.G << 8)) + (base.lineColor.B << 0x10), ",", base.direction, ",", base.pointX, ",", base.pointY, ",", base.sizeDefineWidth, ",", 
                base.sizeDefineHeight, ",", base.txtSize, ",", ((base.txtColor.B << 0x10) + (base.txtColor.G << 8)) + base.txtColor.R, ",", base.txtFont.Trim(), ",", base.isHideTxt ? "1" : "0"
             });
        }

        public override void xuanzhuan180(Point center)
        {
            base.xuanzhuan180(center);
            if (!base.subType.Equals("1"))
            {
                base.pointY -= base.sizeDefine.Height;
                base.pointX -= base.sizeDefineHeight;
            }
            else
            {
                base.pointX--;
                base.pointY -= 2;
            }
        }
    }
}

